<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/**
<span class='line'>  2</span>  * @fileOverview Castle游戏运行配置参数类源文件
<span class='line'>  3</span>  * @author &lt;a href="http://sivory.my.phpcloud.com">Sivory&lt;/a>
<span class='line'>  4</span>  * @version 0
<span class='line'>  5</span>  */</span><span class="WHIT">
<span class='line'>  6</span> 
<span class='line'>  7</span> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>  8</span> 
<span class='line'>  9</span> </span><span class="WHIT">	</span><span class="COMM">/** @exports _Class as Name.Sivory.Castle.Core.Config */</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="WHIT">	</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">_Class</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT">
<span class='line'> 11</span> 
<span class='line'> 12</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 13</span> 	 * @class Castle游戏运行配置参数类。主要功能是向游戏内核提供基本配置参数。由用户建立后传入Game类的构造函数，Game类构造函数可接受匿名创建的Config实例。
<span class='line'> 14</span> 	 * @example new Name.Sivory.Castle.Core.Game({gameKey:"003332",width:800,height:600});
<span class='line'> 15</span> 	 * @author &lt;a href="http://sivory.my.phpcloud.com">Sivory&lt;/a>
<span class='line'> 16</span> 	 * @version 0
<span class='line'> 17</span> 	 * @see Name.Sivory.Castle.Core.Game
<span class='line'> 18</span> 	 */</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT">	</span><span class="NAME">Name.Sivory.Castle.Core.Config</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 20</span> 
<span class='line'> 21</span> </span><span class="WHIT">			</span><span class="COMM">//引用实例</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="WHIT">			</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">instance</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 23</span> 
<span class='line'> 24</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 25</span> 			 * @public
<span class='line'> 26</span> 			 * @field
<span class='line'> 27</span> 			 * @type String
<span class='line'> 28</span> 			 * @description 游戏容器的id，推荐使用div元素。Castle将在此元素中新建一个canvas元素。
<span class='line'> 29</span> 			 * @default "open-sea-game"
<span class='line'> 30</span> 			 * @since 0
<span class='line'> 31</span> 			 */</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">			</span><span class="NAME">this.gameContainer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"open-sea-game"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 33</span> 
<span class='line'> 34</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 35</span> 			 * @public
<span class='line'> 36</span> 			 * @field
<span class='line'> 37</span> 			 * @type String
<span class='line'> 38</span> 			 * @description 游戏的资源文件路径。
<span class='line'> 39</span> 			 * @default "../resource/resource.xml"
<span class='line'> 40</span> 			 * @since 0
<span class='line'> 41</span> 			 */</span><span class="WHIT">
<span class='line'> 42</span> </span><span class="WHIT">			</span><span class="NAME">this.resource</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"../resource/resource.xml"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 43</span> 
<span class='line'> 44</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 45</span> 			 * @public
<span class='line'> 46</span> 			 * @field
<span class='line'> 47</span> 			 * @type String
<span class='line'> 48</span> 			 * @description 游戏资源的类型，可选为“xml”与“json”。当选择“xml”时，则要求资源返回数据必须是纯XML文本，当选择“json”时，则要求资源返回数据必须是{status:...,info:...,data:...}结构的JSON字符串。其中status可选0,1来表示请求是否成功。info值为若请求失败时失败的信息。data值为请求的XML文本。
<span class='line'> 49</span> 			 * @default "xml"
<span class='line'> 50</span> 			 * @since 0
<span class='line'> 51</span> 			 */</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">			</span><span class="NAME">this.resourceType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"xml"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 53</span> 
<span class='line'> 54</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 55</span> 			 * @public
<span class='line'> 56</span> 			 * @field
<span class='line'> 57</span> 			 * @type Number
<span class='line'> 58</span> 			 * @description 游戏运行时的帧率，单位为frame/s
<span class='line'> 59</span> 			 * @default 60
<span class='line'> 60</span> 			 * @since 0
<span class='line'> 61</span> 			 */</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">			</span><span class="NAME">this.fps</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">60</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> 
<span class='line'> 64</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 65</span> 			 * @public
<span class='line'> 66</span> 			 * @field
<span class='line'> 67</span> 			 * @type String
<span class='line'> 68</span> 			 * @description 游戏入口界面id，可以是menu类资源id或是scene类资源id，此id须在XML文档中定义。
<span class='line'> 69</span> 			 * @default "mainMenu"
<span class='line'> 70</span> 			 * @since 0
<span class='line'> 71</span> 			 */</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT">			</span><span class="NAME">this.entryInterface</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"mainMenu"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> 
<span class='line'> 74</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 75</span> 			 * @public
<span class='line'> 76</span> 			 * @field
<span class='line'> 77</span> 			 * @type String
<span class='line'> 78</span> 			 * @description 游戏入口界面的类型，目前可选menu、scene或是battle。
<span class='line'> 79</span> 			 * @default "menu"
<span class='line'> 80</span> 			 * @since 0
<span class='line'> 81</span> 			 */</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">			</span><span class="NAME">this.entryInterfaceType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"menu"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> 
<span class='line'> 84</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 85</span> 			 * @public
<span class='line'> 86</span> 			 * @field
<span class='line'> 87</span> 			 * @type Number
<span class='line'> 88</span> 			 * @description 键盘按键延时。当玩家按住某个键不动时，将以此时间为间隔周期地触发按键事件。单位为毫秒。
<span class='line'> 89</span> 			 * @default 500
<span class='line'> 90</span> 			 * @since 0
<span class='line'> 91</span> 			 */</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">			</span><span class="NAME">this.keyDelay</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">500</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 93</span> 
<span class='line'> 94</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'> 95</span> 			 * @public
<span class='line'> 96</span> 			 * @field
<span class='line'> 97</span> 			 * @type Number
<span class='line'> 98</span> 			 * @description 游戏画布宽度。单位为像素。
<span class='line'> 99</span> 			 * @default 600
<span class='line'>100</span> 			 * @since 0
<span class='line'>101</span> 			 */</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">			</span><span class="NAME">this.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">600</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> 
<span class='line'>104</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>105</span> 			 * @public
<span class='line'>106</span> 			 * @field
<span class='line'>107</span> 			 * @type Number
<span class='line'>108</span> 			 * @description 游戏画布高度。单位为像素。
<span class='line'>109</span> 			 * @default 500
<span class='line'>110</span> 			 * @since 0
<span class='line'>111</span> 			 */</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">			</span><span class="NAME">this.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">500</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> 
<span class='line'>114</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>115</span> 			 * @public
<span class='line'>116</span> 			 * @field
<span class='line'>117</span> 			 * @type Number
<span class='line'>118</span> 			 * @description 游戏单元格宽度。单位为像素。
<span class='line'>119</span> 			 * @default 32
<span class='line'>120</span> 			 * @since 0
<span class='line'>121</span> 			 */</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">			</span><span class="NAME">this.squarewidth</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>123</span> 
<span class='line'>124</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>125</span> 			 * @public
<span class='line'>126</span> 			 * @field
<span class='line'>127</span> 			 * @type Number
<span class='line'>128</span> 			 * @description 游戏单元格高度。单位为像素。
<span class='line'>129</span> 			 * @default 32
<span class='line'>130</span> 			 * @since 0
<span class='line'>131</span> 			 */</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT">			</span><span class="NAME">this.squareheight</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">32</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> 
<span class='line'>134</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>135</span> 			 * @public
<span class='line'>136</span> 			 * @field
<span class='line'>137</span> 			 * @type Boolean
<span class='line'>138</span> 			 * @description 游戏调试模式开关。开启调试模式时，会在界面显示游戏数据。
<span class='line'>139</span> 			 * @default false
<span class='line'>140</span> 			 * @since 0
<span class='line'>141</span> 			 */</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT">			</span><span class="NAME">this.debug</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>143</span> 
<span class='line'>144</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>145</span> 			 * @public
<span class='line'>146</span> 			 * @field
<span class='line'>147</span> 			 * @type String
<span class='line'>148</span> 			 * @description 游戏标识。用于游戏本地存储时区分不同游戏。原则上，一个游戏对应一个固定的游戏标识。取值为任意字符串。
<span class='line'>149</span> 			 * @default "default"
<span class='line'>150</span> 			 * @since 0
<span class='line'>151</span> 			 */</span><span class="WHIT">
<span class='line'>152</span> </span><span class="WHIT">			</span><span class="NAME">this.gameKey</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"default"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>153</span> 
<span class='line'>154</span> </span><span class="WHIT">			</span><span class="COMM">/**
<span class='line'>155</span> 			 * @public
<span class='line'>156</span> 			 * @field
<span class='line'>157</span> 			 * @type Array
<span class='line'>158</span> 			 * @description 游戏全局资源，即需要被优先加载的资源。格式参考默认值。
<span class='line'>159</span> 			 * @default [{id:"key-config",type:"keys"},{id:"initial-team",type:"team"}]
<span class='line'>160</span> 			 * @since 0
<span class='line'>161</span> 			 */</span><span class="WHIT">
<span class='line'>162</span> </span><span class="WHIT">			</span><span class="NAME">this.mustLoad</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>163</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"key-config"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>164</span> </span><span class="WHIT">				</span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"keys"</span><span class="WHIT">
<span class='line'>165</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>166</span> </span><span class="WHIT">				</span><span class="NAME">id</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"initial-team"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>167</span> </span><span class="WHIT">				</span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"team"</span><span class="WHIT">
<span class='line'>168</span> </span><span class="WHIT">			</span><span class="PUNC">}</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'>172</span> 	 * @public
<span class='line'>173</span> 	 * @function
<span class='line'>174</span> 	 * @description 将另一个配置对象并入当前实例。
<span class='line'>175</span> 	 * @param {Name.Sivory.Castle.Config} config
<span class='line'>176</span> 	 * @since 0
<span class='line'>177</span> 	 */</span><span class="WHIT">
<span class='line'>178</span> </span><span class="WHIT">	</span><span class="NAME">_Class.prototype.combine</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>179</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">config</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">		</span><span class="KEYW">for</span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">instance</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'>181</span> </span><span class="WHIT">		</span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">config</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">"function"</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">instance</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">config</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>182</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>183</span> 
<span class='line'>184</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>